﻿namespace EasyWeb.Data.EntityFramework.Models
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using EasyWeb.Data.EntityFramework.Models.Mapping;

    internal class EWDbContext : DbContext
    {
        static EWDbContext()
        {
            Database.SetInitializer<EWDbContext>(null);
        }

        public EWDbContext()
            : base("Name=EasyWeb")
        {
        }

        public DbSet<EWConfigurationModel> Configurations { get; set; }
        public DbSet<EWCultureModel> Cultures { get; set; }
        public DbSet<EWEntityDefinitionModel> EntityDefinitions { get; set; }
        public DbSet<EWFieldDefinitionModel> FieldDefinitions { get; set; }
        public DbSet<EWSelectionDefinitionModel> SelectionDefinitions { get; set; }
        public DbSet<EWSelectionItemDefinitionModel> SelectionItemDefinitions { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new EWConfigurationModelMapping());
            modelBuilder.Configurations.Add(new EWCultureModelMapping());
            modelBuilder.Configurations.Add(new EWEntityDefinitionModelMapping());
            modelBuilder.Configurations.Add(new EWFieldDefinitionModelMapping());
            modelBuilder.Configurations.Add(new EWSelectionDefinitionModelMapping());
            modelBuilder.Configurations.Add(new EWSelectionItemDefinitionModelMapping());
        }
    }
}
